const UserController = require('../controller/user.js');
const StoreController = require('../controller/store.js')
const ImageController = require('../controller/image.js')
const SeatController = require('../controller/seat.js')
const CategoryController =  require('../controller/category.js')
const Router = require('koa-router');

const router = new Router();

//checkToken作为中间件存在
const checkToken = require('../token/checkToken.js');
router.post('/login', UserController.Login);
router.post('/register', UserController.Reg);

//需要先检查权限的路由
router.get('/user', checkToken, UserController.GetAllUsers);
router.post('/delUser', checkToken, UserController.DelUser);

router.post('/store/add', checkToken, StoreController.Insert)
router.get('/store/get', checkToken, StoreController.Fetch)

router.post('/seat/add', checkToken, SeatController.Insert)
router.get('/seat/get', checkToken, SeatController.Fetch)
router.post('/seat/update', checkToken, SeatController.Update)
router.post('/seat/delete', checkToken, SeatController.Delete)

router.post('/category/add', checkToken, CategoryController.Insert)
router.get('/category/get', checkToken, CategoryController.Fetch)
router.post('/category/update', checkToken, CategoryController.Update)
router.post('/category/delete', checkToken, CategoryController.Delete)

router.post('/image/upload', checkToken, ImageController.Upload)
module.exports = router;